package christ.mmd.bl;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.os.Parcel;
import android.os.Parcelable;

public class Image implements Parcelable {
	public enum Type {
		logo, icon, banner, photo, map
	}

	Type mType;
	String mUrl;
	Bitmap mImage = Bitmap.createBitmap(1, 1, Config.ARGB_8888);

	public Image(String type, String url) {
		mType = Type.valueOf(type);
		mUrl = url;
	}

	public Image(Parcel in) {
		this(in.readString(), in.readString());

		mImage = Bitmap.CREATOR.createFromParcel(in);
	}

	public Type getType() {
		return mType;
	}

	public String getUrl() {
		return mUrl;
	}

	public void updateBitmap(Bitmap image) {
		mImage = image;
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(mType.name());
		dest.writeString(mUrl);
		mImage.writeToParcel(dest, PARCELABLE_WRITE_RETURN_VALUE);
	}

	public static final Parcelable.Creator<Image> CREATOR = new Parcelable.Creator<Image>() {
		public Image createFromParcel(Parcel in) {
			return new Image(in);
		}

		public Image[] newArray(int size) {
			return new Image[size];
		}
	};
}
